package com.example.Annocation.importTry;

import com.example.Annocation.commons.Defination;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @Description TODO
 * @Date 2024/5/15 0:23
 * @Created by houjunfeng
 */
public class MyImportBeanDefination implements ImportBeanDefinitionRegistrar {
    //var2 为容器的bean注册信息
    @Override
    public  void registerBeanDefinitions(AnnotationMetadata var1, BeanDefinitionRegistry beanDefinitionRegistry){
        boolean register1 = beanDefinitionRegistry.containsBeanDefinition("com.example.annocation.commons.Color");
        boolean register2 = beanDefinitionRegistry.containsBeanDefinition("com.example.annocation.commons.Red");
        if(register1&&register2){
            RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(Defination.class);
            beanDefinitionRegistry.registerBeanDefinition("Defination",rootBeanDefinition);
        }
    }
}
